#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n = 0;
    cin >> n;
    vector<int> arr;
    arr.resize(n + 1);
    arr[n] = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int i = 0;
    int count = 0;
    while (i < n)
    {
        if (arr[i] < arr[i + 1])
        {
            while (i < n && arr[i] <= arr[i + 1])
            {
                i++;
            }
            count++;
            i++;
        }
        else if (arr[i] == arr[i + 1])
        {
            i++;
        }
        else
        {
            while (i < n && arr[i] >= arr[i + 1])
            {
                i++;
            }
            count++;
            i++;
        }
    }
    cout << count << endl;
    return 0;
}